import { http, httpR2 } from "@/utils/http";
import type { User, UserInfoUpdate } from "../types/myInfo";
import { useMemberStore } from "@/stores";
import { BaseURL } from "@/stores/modules/base";

export const updateUserInfo = (userInfoUpdate: UserInfoUpdate) => {
  return httpR2<String>({
    method: "PUT",
    url: BaseURL + "/user/user/",
    header: {
      authorization: useMemberStore().profile.authorization,
    },
    data: {
      ...userInfoUpdate,
    },
  });
};

export const updateTeacherInfo = (userInfoUpdate: UserInfoUpdate) => {
  return httpR2<String>({
    method: "PUT",
    url: BaseURL + "/user/user",
    header: {
      authorization: useMemberStore().profile.authorization,
    },
    data: {
      ...userInfoUpdate,
    },
  });
};

export const getUserCurrInfo = () => {
  return httpR2<User>({
    method: "POST",
    url: BaseURL + "/user/user/myInfo",
    header: {
      authorization: useMemberStore().profile.authorization,
    },
    data: {},
  });
};
